package com.itheima.edu.info.manager.utils;

import java.util.Scanner;
import java.util.regex.Pattern;

public class InputUtils {
    static Scanner sc = new Scanner(System.in);

    //正则表达式进行输入的格式判断
    public static String inputRule(String rule){
        String inputMsg;
        while (true){
            inputMsg = sc.next();
            //System.out.println("rule = " + rule);
            if (!Pattern.matches(rule,inputMsg)){
                System.out.println("输入的格式有误,请重新输入");
            }else
                break;
        }
        //System.out.println("inputMsg = " + inputMsg);
        return inputMsg;
    }
}
